package ldkxingzhe.l365calendar.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import ldkxingzhe.l365calendar.R;
import ldkxingzhe.l365calendar.widget.dialog.DialogFragmentBase;
import ldkxingzhe.l365calendar.widget.dialog.picker.TimePicker;

/**
 * Created by ke on 16-1-26.
 */
public class MainDiscovery extends Fragment implements HandleFragmentResult{
    @SuppressWarnings("unused")
    private static final String TAG = "DiscoveryFragment";

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View resultView = inflater.inflate(R.layout.fragment_main_discovery, container, false);
        resultView.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String[] array = new String[]{"推出", "拍照", "从相册获取", "知道了"};
                DialogFragmentBase fragment = TimePicker.newInstance(4, 45);
                fragment.setTargetFragment(MainDiscovery.this, 0);
                fragment.show(getFragmentManager(), "Dialog");
            }
        });
        return resultView;
    }


    @Override
    public void onHandleFragmentResult(int requestCode, int resultCode, Intent data) {
        Log.v(TAG, "requestCode is " + requestCode + ", and resultCode is " + resultCode);
        if(data != null){
            Log.v(TAG, "result is " + data.getIntExtra(TimePicker.HOUR, -1));
            Log.v(TAG, "minute is " + data.getIntExtra(TimePicker.MINUTE, -1));
        }
    }
}
